﻿#VisualFreeBasic_Form#  Version=5.5.7
Locked=0

[Form]
Name=Form1
ClassStyle=CS_VREDRAW,CS_HREDRAW,CS_DBLCLKS
ClassName=
WinStyle=WS_THICKFRAME,WS_CAPTION,WS_SYSMENU,WS_MINIMIZEBOX,WS_CLIPSIBLINGS,WS_CLIPCHILDREN,WS_VISIBLE,WS_EX_WINDOWEDGE,WS_EX_CONTROLPARENT,WS_EX_LEFT,WS_EX_LTRREADING,WS_EX_RIGHTSCROLLBAR,WS_POPUP,WS_SIZEBOX
Style=3 - 常规窗口
Icon=APP.ico
Caption=ChromePak
StartPosition=1 - 屏幕中心
WindowState=0 - 正常
Enabled=True
Repeat=False
Left=0
Top=0
Width=520
Height=450
TopMost=False
Child=False
MdiChild=False
TitleBar=True
SizeBox=True
SysMenu=True
MaximizeBox=False
MinimizeBox=True
Help=False
Hscroll=False
Vscroll=False
MinWidth=0
MinHeight=0
MaxWidth=0
MaxHeight=0
NoActivate=False
MousePass=False
TransPer=0
TransColor=SYS,25
Shadow=0 - 无阴影
BackColor=SYS,15
MousePointer=0 - 默认
Tag=
Tab=True
ToolTip=
ToolTipBalloon=False
AcceptFiles=False

[TextBox]
Name=Text1
Index=-1
Style=3 - 凹边框
TextScrollBars=0 - 无滚动条
Text=
Enabled=True
Visible=True
MaxLength=0
ForeColor=SYS,8
BackColor=SYS,5
Font=新宋体,12
TextAlign=0 - 左对齐
PasswordChar=
Locked=False
HideSelection=True
Multiline=False
Uppercase=False
Lowercase=False
Number=False
AutoHScroll=True
AutoVScroll=False
Left=70
Top=70
Width=270
Height=30
Layout=0 - 不锚定
MousePointer=0 - 默认
Tag=
Tab=True
ToolTip=源路径
ToolTipBalloon=False
LeftMargin=0
RightMargin=0
AcceptFiles=True

[Button]
Name=Command1
Index=-1
Caption=打包
TextAlign=1 - 居中
Ico=
Enabled=True
Visible=True
Default=False
OwnDraw=False
MultiLine=False
Font=新宋体,16,1
Left=70
Top=280
Width=160
Height=60
Layout=0 - 不锚定
MousePointer=0 - 默认
Tag=
Tab=True
ToolTip=
ToolTipBalloon=False

[Button]
Name=Command2
Index=-1
Caption=解包
TextAlign=1 - 居中
Ico=
Enabled=True
Visible=True
Default=False
OwnDraw=False
MultiLine=False
Font=新宋体,16,1
Left=280
Top=280
Width=150
Height=60
Layout=0 - 不锚定
MousePointer=0 - 默认
Tag=
Tab=True
ToolTip=
ToolTipBalloon=False

[Label]
Name=Label1
Index=-1
Style=0 - 无边框
Caption=注:资源文件和本程序需要在同一路径且文件名不能有空格
Enabled=True
Visible=True
ForeColor=SYS,8
BackColor=SYS,25
Font=新宋体,11
TextAlign=4 - 置中
Prefix=True
Ellipsis=False
Left=52
Top=117
Width=400
Height=30
Layout=0 - 不锚定
MousePointer=0 - 默认
Tag=
ToolTip=
ToolTipBalloon=False

[Option]
Name=Option1
Index=-1
Style=0 - 标准
Caption=资源文件
TextAlign=4 - 置中
Alignment=0 - 文本在左边
Value=1 - 选择
Multiline=True
GroupName=OptionGroup1
Enabled=True
Visible=True
ForeColor=SYS,8
BackColor=SYS,25
Font=新宋体,16,1
Left=78
Top=180
Width=120
Height=50
Layout=0 - 不锚定
MousePointer=0 - 默认
Tag=
Tab=True
ToolTip=
ToolTipBalloon=False
AcceptFiles=False

[Option]
Name=Option2
Index=-1
Style=0 - 标准
Caption=语言文件
TextAlign=4 - 置中
Alignment=0 - 文本在左边
Value=0 - 未选择
Multiline=True
GroupName=OptionGroup1
Enabled=True
Visible=True
ForeColor=SYS,8
BackColor=SYS,25
Font=新宋体,16,1
Left=288
Top=180
Width=120
Height=50
Layout=0 - 不锚定
MousePointer=0 - 默认
Tag=
Tab=True
ToolTip=
ToolTipBalloon=False
AcceptFiles=False

[Button]
Name=Command3
Index=-1
Caption=点击选择文件
TextAlign=1 - 居中
Ico=
Enabled=True
Visible=True
Default=True
OwnDraw=False
MultiLine=False
Font=新宋体,9
Left=350
Top=70
Width=80
Height=30
Layout=0 - 不锚定
MousePointer=0 - 默认
Tag=
Tab=True
ToolTip=
ToolTipBalloon=False


[AllCode]
'这是标准的工程模版，你也可做自己的模版。
'写好工程，复制全部文件到VFB软件文件夹里【template】里即可，子文件夹名为 VFB新建工程里显示的名称
'快去打造属于你自己的工程模版吧。

Sub Form1_Command1_BN_Clicked(hWndForm As hWnd ,hWndControl As hWnd) '打包
   If Option1.Value = True Then
      Exec(ExePath & "\pak_tools.exe" ,"-c=repack -f=" & Text1.Text & ".json")
      Kill(ExePath & "\" & Text1.Text & ".json")
      Shell("rd /s /q " & ExePath & "\" & Text1.Text)
   Else
      Exec(ExePath & "\pak_tools.exe" ,"-c=lang_repack -f=" & Text1.Text & ".json")
      Kill(ExePath & "\" & Text1.Text & ".json")
   End If
   Command1.Enabled = False
   Command2.Enabled = True
End Sub

Sub Form1_Command2_BN_Clicked(hWndForm As hWnd ,hWndControl As hWnd) '解包
   If Option1.Value = True Then
      Exec(ExePath & "\pak_tools.exe" ,"-c=unpack -f=" & Text1.Text & ".pak")
      Kill(ExePath & "\" & Text1.Text & ".pak")
   Else
      Exec(ExePath & "\pak_tools.exe" ,"-c=lang_unpack -f=" & Text1.Text & ".pak")
      Kill(ExePath & "\" & Text1.Text & ".pak")
   End If
   Command2.Enabled = False
   Command1.Enabled = True
End Sub

Sub Form1_Shown(hWndForm As hWnd ,UserData As Integer) '窗口完全显示后。UserData 来自显示窗口最后1个参数。
   Command3.Enabled = False
   If FileExists("pak_tools.exe") <> 0 Then
      Text1.Enabled    = False
      Command1.Enabled = False
      Command2.Enabled = False
      Option1.Enabled  = False
      Option2.Enabled  = False
      Option1.Value    = False
      Option2.Value    = False
      Command3.Enabled = True
   Else
      Dim b As String  = GetResourceStr("RCDATA_PAKTOOLS")
      Dim a As Integer = SaveFileStr("pak_tools.exe" ,b)
      If a <> 0 Then
         MsgBox("资源释放失败")
         Form1.Close
      Else
         Text1.Enabled    = False
         Command1.Enabled = False
         Command2.Enabled = False
         Option1.Enabled  = False
         Option2.Enabled  = False
         Option1.Value    = False
         Option2.Value    = False
         Command3.Enabled = True
      End If
   End If
End Sub

Sub Form1_Command3_BN_Clicked(hWndForm As hWnd ,hWndControl As hWnd) '选文件
   Dim nFN As String = FF_OpenFileDialog(hWndForm ,"选择资源文件" , ,ExePath ,"Chrome浏览器专用打包格式.pak|*.pak;*.json" , ,0 ,1)
   Dim fnn As String
   If Len(nFN) <> 0 Then
      fnn = FF_FileName(nFN)
   Else
      Text1.Text       = ""
      Command1.Enabled = False
      Command2.Enabled = False
      Option1.Value    = False
      Option2.Value    = False
      fnn              = ""
   End If
   If Len(fnn) = 0 Then
      Option1.Value = False
      Option2.Value = False
   ElseIf Len(fnn) < 8 Or FF_Tally(fnn ,"-") > 0 Then
      Option2.Value = True
      Option1.Value = False
   Else
      Option1.Value = True
      Option2.Value = False
   End If
   If FF_Tally(fnn ,".json") > 0 Then
      Text1.Text       = FF_StrDelete(fnn ,Len(fnn) -4 ,4)
      Command1.Enabled = True
      Command2.Enabled = False
   ElseIf FF_Tally(fnn ,".pak") > 0 Then
      Text1.Text       = FF_StrDelete(fnn ,Len(fnn) -3 ,3)
      Command2.Enabled = True
      Command1.Enabled = False
   End If
End Sub











